<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./js/plugins/axios.js"></script>
    <script src="./js/plugins/vue.js"></script>
    <script src="./common/common.js"></script>
</head>
<body>
    <dev id="app">

    </dev>
</body>
<!-- 回掉域 扫码之后访问的html-->
<script type="text/javascript">
    new Vue({
        el:"#app",
        methods:{

        },
        /* 访问该接口立马发送请求 */
        mounted(){
            // http://bugtracker.itsource.cn/callback.html?code=061IduGa1839qC02jlIa1NmHxX1IduGX&state=1
            //从地址栏解析code出来
            let parse = parseUrlParams2Obj(location.href)//从地址中获取json
            let params = {
                "code" : parse.code
            }
            //将code返回到后端，获得令牌
            this.$http.post("/login/wechat",params).then(result=>{
                if(result.data.msg =='NOBIND'){
                    //跳转绑定页面
                    location.href = "/bind.html?unionid="+result.data.data
                }else{

                    if(parse.state == "pethome_yyds"){
                        location.href = "/index.html"
                    }else {
                        location.href = "/"+parse.state+".html"
                    }
                    //把对象转换为json字符串存放
                    localStorage.setItem("token",result.data.data.token)
                    localStorage.setItem("userinfo",JSON.stringify(result.data.data.logininfoBO))
                    localStorage.setItem("employee",JSON.stringify(result.data.data.employee))
                    localStorage.setItem("user",JSON.stringify(result.data.data.user))
                    localStorage.setItem("menus",JSON.stringify(result.data.data.menus))
                    localStorage.setItem("permissions",JSON.stringify(result.data.data.permissions))
                }

            })
        }
    })

</script>
</html>